package com.spring.boot.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.spring.boot.entity.CollectAndPay;
import com.spring.boot.entity.Contract;
import com.spring.boot.vo.ContractParametersVO;
import com.spring.boot.vo.StatisticsVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Author: Daniel ZTQ
 * @Date: 2021/01/01 12:13
 * @Description: TODO
 */
@Service
public interface CollectAndPayMapper extends BaseMapper<CollectAndPay> {
    /**
     * 根据日期查询收入金额
     * */
    @Select("SELECT sum(money) as money " +
            "FROM collect_and_pay " +
            "where type='0' and created_time like CONCAT('%',#{date},'%') ")
    Double  getIncomeMoney(@Param("date")String date);

    /**
     * 根据日期查询支出金额
     * */
    @Select("SELECT sum(money) as money " +
            "FROM collect_and_pay " +
            "where type='1' and created_time like CONCAT('%',#{date},'%') ")
    Double  getExpenditureMoney(@Param("date")String date);


    /**
     * 统计
     * */
    @Select("select COUNT(1) as number,type,a.created_time from (select type,left(created_time,10) as created_time FROM collect_and_pay) as a GROUP BY type,a.created_time")
    List<StatisticsVO>  getStatistics();

}
